﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTCash.Logger;
using DTCash.Logger.DTO;
using DTCash.Redis;
using Uranus.Service.ContentsService;

namespace Uranus.Service
{
    public class Contents : BaseData
    {
        private static Contents contents = null;

        public static Contents GetContents()
        {
            if (contents == null)
            {
                contents = new Contents();
            }
            return contents;
        }

        /// <summary>
        /// 根据id获取内容管理信息
        /// Date:2017年10月17日10:57:06
        /// Author:Linsan
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ContentsResponse SelectContentsByID(ContentsRequest request)
        {
            ContentsServiceClient contentService = new ContentsServiceClient();
            try
            {
                Func<ContentsResponse> method = delegate
                {
                    ContentsResponse response = contentService.SelectContentsByID(request);
                    return response;
                };
                return GetData<ContentsResponse>(method, CacheItem.InitByIdentity(request.Info.ContentID.ToString(), "Contents").Other.Message);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(LogEnum.Error, "根据id获取内容管理信息 失败 SelectContentsByID", ex.Message.ToString(), null);
                return null;
            }
            finally
            {
                contentService.Close();
            }
        }
    }
}
